#ifndef __PTGUI_FILERW_H__
#define __PTGUI_FILERW_H__

#define PTGUI_FILE_SEEK_SET	0
#define PTGUI_FILE_SEEK_CUR	1
#define PTGUI_FILE_SEEK_END	2

struct pt_filerw
{
	int (*seek) (struct pt_filerw *context, pt_off_t offset, int whence);
	int (*read) (struct pt_filerw *context, void *buffer, pt_size_t size, pt_size_t count);
	int (*write)(struct pt_filerw *context, const void *buffer, pt_size_t size, pt_size_t count);
	int (*tell) (struct pt_filerw *context);
	int (*eof)	(struct pt_filerw *context);
	int (*close)(struct pt_filerw *context);
};
typedef struct pt_filerw pt_filerw_t;

struct pt_filerw *pt_filerw_create_file(const pt_char_t *filename, const pt_char_t *mode);
struct pt_filerw *pt_filerw_create_mem(const pt_uint8_t *mem, pt_size_t size);

int pt_filerw_seek(struct pt_filerw *context, pt_off_t offset, int whence);
int pt_filerw_read(struct pt_filerw *context, void *buffer, pt_size_t size, pt_size_t count);
int pt_filerw_write(struct pt_filerw *context, const void *buffer, pt_size_t size, pt_size_t count);
int pt_filerw_tell(struct pt_filerw *context);
int pt_filerw_eof(struct pt_filerw *context);
int pt_filerw_close(struct pt_filerw *context);

/* get memory data from filerw memory object */
const pt_uint8_t *pt_filerw_mem_getdata(struct pt_filerw *context);

#endif
